package com.toubutu.audio.controller;

import com.toubutu.audio.dto.CheckFileExistDto;
import com.toubutu.audio.dto.PageQueryVideoDto;
import com.toubutu.audio.service.VideoService;
import com.toubutu.audio.vo.SeqVideoItem;
import com.toubutu.audio.vo.VideoListItemVo;
import com.toubutu.audio.vo.VideoVo;
import com.toubutu.common.PageUtils;
import com.toubutu.common.Result;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 戒躁
 * @since 2024-01-08
 */
@RestController
@RequestMapping("/video")
public class VideoController {
    @Resource
    private VideoService videoService;
    @GetMapping("/info/{videoCode}")
    public Result<VideoVo> getVideoInfo(@PathVariable String videoCode){
        return Result.ok(videoService.getVideoInfoByCode(videoCode));
    }

    @PostMapping("/list")
    public Result<PageUtils<VideoListItemVo>> getVideoList(@RequestBody PageQueryVideoDto videoDto){
        return Result.ok(videoService.getVideoList(videoDto));
    }
    @GetMapping("/range/{size}")
    public Result<List<VideoListItemVo>> rangVideo(@PathVariable("size")Integer size){
        return Result.ok(videoService.getRangeVideoList(size));
    }
    @PostMapping("/search")
    public Result<PageUtils<VideoListItemVo>> search(@RequestBody @Valid PageQueryVideoDto videoDto){
        return Result.ok(videoService.getVideoList(videoDto));
    }

    @GetMapping("/seq/{videoId}")
    public Result<List<SeqVideoItem>> getAllSeq(@PathVariable("videoId")Integer videoId){
        return Result.ok(videoService.getVideoSeqList(videoId));
    }


}
